package com.gzw.dms.utils;

import com.gzw.dms.bean.Constant;
import com.loopj.android.http.AsyncHttpClient;
import com.loopj.android.http.AsyncHttpResponseHandler;
import com.loopj.android.http.RequestParams;

/**
 * Created by GaoZhiWei on 2016/2/22.
 */
public class TwitterRestClient {
    private  static  String BASE_URL ;
    private static AsyncHttpClient client = new AsyncHttpClient();
    private final static String lag="TwitterRestClient---->";

    public static void get(String url, RequestParams params, AsyncHttpResponseHandler responseHandler) {
        client.get(getAbsoluteUrl(url), params, responseHandler);
    }
    public static void post(String url, RequestParams params, AsyncHttpResponseHandler responseHandler) {
        client.post(getAbsoluteUrl(url), params, responseHandler);
    }
    private static String getAbsoluteUrl(String relativeUrl) {
        BASE_URL=PropertiesUtil.Read(Constant.IP_KEY)+PropertiesUtil.Read(Constant.SERVICE_URL_KEY);
        if (relativeUrl != null) {
             BASE_URL += relativeUrl;
        }
        L.i(lag,BASE_URL);
        return BASE_URL;
    }
}
